/*
 * Main.java
 *
 * Created on February 7, 2007, 6:48 PM
 */

/**
 *
 * @author  Sujal Bista
 */
import java.sql.*;
import java.io.*;
import java.util.Vector;
import javax.sql.*;
import java.lang.Math;
import java.util.HashSet;
import javax.swing.*;
import java.util.StringTokenizer;



public class Main extends javax.swing.JFrame {

//    //terpwushu.org's 1and1 account does not have remote mysql access
//    String databaseNameSQL="db217506540";
//    String userNameSQL="dbo217506540";
//    String serverURLSQL="db1110.perfora.net";
//    String passwordSQL="xxxx";

    String databaseNameSQL="wushu";
    String userNameSQL="root";
    String serverURLSQL="localhost:3306";
    String passwordSQL="xxxx";

    String MySQLDriver="com.mysql.jdbc.Driver";
    String querySQL =
//              //for old database without groupA, groupb, groupc          
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Changquan'              AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.changquan=true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nanquan'                AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.nanquan=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan'              AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.taijibarenandu=true  ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanNoNandu'       AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.cq=true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanNoNandu'         AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nq=true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Straightsword'          AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.ssword=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Broadsword'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.bsword=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nandao'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nandao=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Staff'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.staff=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Spear'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.spear=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nangun'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nangun=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenBarehand'           AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.obare=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenWeapon'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.oweapon=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiquanNoNandu'       AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.taijibare=true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiWeapon'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.taijiweapon=true     ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NorthTradionalBarehand' AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.northtradbare=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NorthTradionalWeapon'   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.northtradweapon=true ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SouthTradionalBarehand' AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.southtradbare=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SouthTradionalWeapon'   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.southtradweap=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'GroupSet'               AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.groupset=true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SparringSet'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id AND events.sparset=true ORDER BY athletes.sex,athletes.xp,athletes.id)";
            
            //for new for university games
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Changquan'              AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.changquan=true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nanquan'                AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.nanquan=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanNoNandu'       AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.cq=true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanNoNandu'         AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nq=true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanA'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.cq_A=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanB'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.cq_B=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanC'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.cq_C=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanA'               AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nq_A=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanB'               AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nq_B=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanC'               AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nq_C=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StraightswordA'         AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.ss_A=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StraightswordB'         AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.ss_B=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StraightswordC'         AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.ss_C=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'BroadswordA'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.bs_A=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'BroadswordB'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.bs_B=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'BroadswordC'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.bs_C=true	           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SpearA'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.spear_A=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SpearB'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.spear_B=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SpearC'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.spear_C=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StaffA'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.staff_A=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StaffB'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.staff_B=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'StaffC'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.staff_C=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NandaoA'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nd_A=true            ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NandaoB'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nd_B=true            ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NandaoC'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nd_C=true            ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NangunA'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nangun_A=true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NangunB'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nangun_B=true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NangunC'                AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nangun_C=true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Straightsword'          AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.ssword=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Broadsword'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.bsword=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nandao'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nandao=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Staff'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.staff=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Spear'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.spear=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nangun'                 AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.nangun=true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenBarehand'           AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.obare=true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenWeapon'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.oweapon=true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiquanNoNandu'       AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.taijibare=true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiWeapon'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.taijiweapon=true     ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan'              AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.taijibarenandu=true  ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NorthTradionalBarehand' AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.northtradbare=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NorthTradionalWeapon'   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.northtradweapon=true ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SouthTradionalBarehand' AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.southtradbare=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SouthTradionalWeapon'   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.southtradweap=true   ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'GroupSet'               AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.groupset=true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION "+
            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'SparringSet'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events,nandu WHERE athletes.id=events.id                          AND events.sparset=true         ORDER BY athletes.sex,athletes.xp,athletes.id)";

//            //used for collegiates
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Changquan'               AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.changquan = true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nanquan'                 AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.nanquan = true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan'               AS Events, nandu.s1nandu,nandu.s2nandu,nandu.s3nandu,nandu.s4nandu FROM athletes,events,nandu WHERE athletes.id=events.id AND athletes.id=nandu.id AND events.taijibarenandu = true  ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'ChangquanNoNandu'        AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.cq = true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'NanquanNoNandu'          AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nq = true              ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Straightsword'           AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.ssword = true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Broadsword'              AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.bsword = true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nandao'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nandao = true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Staff'                   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.staff = true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Spear'                   AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.spear = true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Nangun'                  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.nangun = true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenBarehand'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.obare = true           ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'OpenWeapon'              AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.oweapon = true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiWeapon'             AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.taijiweapon = true     ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan_24'	     AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.taiji24 = true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan_Yang'	     AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.yang = true            ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan_Chen'	     AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.chen = true            ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Taijiquan_Fist_42'       AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.fist42 = true          ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'TaijiWeapon_Sword_42'    AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.sword42 = true         ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Intro_Weapon'            AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.intoweap = true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Intro_Barehand'          AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.intobare = true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Traditional_Barehand'    AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.tradbare = true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Traditional_LongWeapon'  AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.tradlong = true        ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Traditional_ShortWeapon' AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.tradshort = true       ORDER BY athletes.sex,athletes.xp,athletes.id) UNION " +
//            "(SELECT athletes.id AS AthleteID, athletes.fname AS fname, athletes.lname AS lname, athletes.email AS Email, athletes.sex AS Gender, athletes.college AS College, athletes.school AS School, athletes.xp AS Level, athletes.agegroup AS AgeGroup, 'Traditional_Soft'        AS Events, '' as nandu1,'' as nandu2,'' as nandu3,'' as nandu4     FROM athletes,events       WHERE athletes.id=events.id                          AND events.tradsoft = true        ORDER BY athletes.sex,athletes.xp,athletes.id)";


    //not used much used for EXCEL database
    public static final String ODBCDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    public String excelDBUrl = "jdbc:odbc:tournament";
    public  String queryExcel = "select * from [tournament$]";
    
    
    public static nanduData nandu;
    public static  String invalidNandu;
    ModifyAthletes modifyAthletes;
    Viewer viewerAthletes;
    public static readSetupFile setupInfo;
    
    /** Creates new form Main */
    public Main() {

        initComponents();
        globalData.initGlobalData();
        setupInfo=new readSetupFile();
        nandu=new nanduData();
        invalidNandu=new String();

        DatabaseT.setText(databaseNameSQL);
        UserNameT.setText(userNameSQL);
        ServerURLT.setText(serverURLSQL);
        PasswordT.setText(passwordSQL);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Output = new javax.swing.JTextArea();
        Command = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        DatabaseT = new javax.swing.JTextField();
        DownloadSQL = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        DownloadFileNameT = new javax.swing.JTextField();
        UserNameT = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        ServerURLT = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        PasswordT = new javax.swing.JPasswordField();
        jPanel6 = new javax.swing.JPanel();
        AddAthletesB = new javax.swing.JButton();
        ModifyAthletesB = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        src1 = new javax.swing.JTextField();
        src2 = new javax.swing.JTextField();
        out = new javax.swing.JTextField();
        merge = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        ReadDataFromTextFile = new javax.swing.JButton();
        PrintEventReport = new javax.swing.JButton();
        RandomizeOrder = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Database Manager");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("SQL Query (for some random queries)"));
        jPanel3.setMinimumSize(new java.awt.Dimension(400, 300));
        jPanel3.setPreferredSize(new java.awt.Dimension(400, 300));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jScrollPane1.setViewportView(Output);

        jPanel3.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, 970, 220));

        Command.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        Command.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                CommandKeyPressed(evt);
            }
        });
        jPanel3.add(Command, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, 970, 30));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel4.setText("Command ( eg. select * from athletes )");
        jPanel3.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel5.setText("Output");
        jPanel3.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, -1, -1));

        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 260, 1010, 350));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Download SQL data for program to use"));
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setText("SQL Database");
        jPanel4.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));

        DatabaseT.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        DatabaseT.setText("wushu");
        jPanel4.add(DatabaseT, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 20, 800, -1));

        DownloadSQL.setText("DownloadSQL");
        DownloadSQL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DownloadSQLActionPerformed(evt);
            }
        });
        jPanel4.add(DownloadSQL, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 220, -1, -1));

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel9.setText("Download FileName");
        jPanel4.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 180, -1, -1));

        DownloadFileNameT.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        DownloadFileNameT.setText("../data/athletes.txt");
        jPanel4.add(DownloadFileNameT, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 180, 800, -1));

        UserNameT.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        UserNameT.setText("root");
        jPanel4.add(UserNameT, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 60, 800, -1));

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel10.setText("User Name");
        jPanel4.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, -1, -1));

        ServerURLT.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        ServerURLT.setText("localhost:3306");
        jPanel4.add(ServerURLT, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 100, 800, -1));

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel11.setText("SQL Server URL");
        jPanel4.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel12.setText("Password");
        jPanel4.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, -1, -1));
        jPanel4.add(PasswordT, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 140, 800, 30));

        getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1010, 260));

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Manage Athletes (used to directly add/ modify athletes. Spelling/case has to match perfectly. This is a last minute option. Adding/modifying data to SQL is preferred)"));
        jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        AddAthletesB.setText("Add Athletes");
        AddAthletesB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddAthletesBActionPerformed(evt);
            }
        });
        jPanel6.add(AddAthletesB, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 30, 190, 30));

        ModifyAthletesB.setText("Modify Athletes");
        ModifyAthletesB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ModifyAthletesBActionPerformed(evt);
            }
        });
        jPanel6.add(ModifyAthletesB, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 30, 200, 30));

        getContentPane().add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 610, 1010, 80));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Merge Result Files (merge results from different floors)"));
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel6.setText("Output");
        jPanel5.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 30, -1, -1));

        src1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        src1.setText("../data/athletes1.txt");
        jPanel5.add(src1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 320, -1));

        src2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        src2.setText("../data/athletes2.txt");
        jPanel5.add(src2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 60, 320, -1));

        out.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        out.setText("../data/athletesMerged.txt");
        jPanel5.add(out, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 30, 290, -1));

        merge.setText("Merge");
        merge.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mergeActionPerformed(evt);
            }
        });
        jPanel5.add(merge, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 60, 230, -1));

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel7.setText("Source 1");
        jPanel5.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, -1, -1));

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel8.setText("Source 2");
        jPanel5.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, -1, -1));

        getContentPane().add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 820, 1010, 100));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Tools"));
        jPanel1.setName(""); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        ReadDataFromTextFile.setText("Read Athlete database from text file");
        ReadDataFromTextFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ReadDataFromTextFileActionPerformed(evt);
            }
        });
        jPanel1.add(ReadDataFromTextFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 30, -1, 30));

        PrintEventReport.setText("Print Event Report");
        PrintEventReport.setActionCommand("");
        PrintEventReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrintEventReportActionPerformed(evt);
            }
        });
        jPanel1.add(PrintEventReport, new org.netbeans.lib.awtextra.AbsoluteConstraints(720, 30, -1, 30));

        RandomizeOrder.setText("Randomize Athletes Order");
        RandomizeOrder.setActionCommand("");
        RandomizeOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RandomizeOrderActionPerformed(evt);
            }
        });
        jPanel1.add(RandomizeOrder, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 30, -1, 30));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 690, 1010, 130));
        jPanel1.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //returns the type of the scoring system
    // 0 Traditional System := TraditionalSystem
    // 1 Compulsary Nandu := CompulsorySystem
    // 2 Nandu System := NanduSystem
    public int getScoringSystem(String level, String eventName)
    {
        for(int i=0; i<globalData.scoringSystemInfo.length;i++)
        {
            if(globalData.scoringSystemInfo[i].eventName.equals(eventName) &&
                    globalData.scoringSystemInfo[i].level.equals(level))
            {
                if(globalData.scoringSystemInfo[i].scoringType.equals("TraditionalSystem"))
                    return 0;
                else if(globalData.scoringSystemInfo[i].scoringType.equals("CompulsorySystem"))
                    return 1;
                else if(globalData.scoringSystemInfo[i].scoringType.equals("NanduSystem"))
                    return 2;
                return 2;
            }
        }
        return 0;
    }
    
    private void CommandKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CommandKeyPressed

        if(evt.getKeyCode()==evt.VK_ENTER)
        {
            Connection connection = null;
             try 
             {
                //for mysql driver
                Class.forName(MySQLDriver).newInstance();
                String databaseURLSQL = "jdbc:mysql://" + ServerURLT.getText() +  "/" + DatabaseT.getText(); // a JDBC url
                connection = DriverManager.getConnection(databaseURLSQL, UserNameT.getText(), PasswordT.getText());
                ////excel based database
                //Class.forName(ODBCDriver).newInstance();
                //connection = DriverManager.getConnection(excelDBUrl);
                Statement statement = connection.createStatement();
                ResultSet results = statement.executeQuery(Command.getText());
                Output.setText("");
                printResult(results);
                results.close();
                statement.close();
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
            }

            //close the connecction do not combine with prev catch because
            //updates doesn't print result 
            try 
            {
                connection.close();
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
            }
            
        }
    }//GEN-LAST:event_CommandKeyPressed

    /////////////////////////////////////////////////////////////
   
    //verif if the nandu is valud
    public boolean verifyNandu(String athleteName,String nanduData,String event)
    {
        boolean retVal=true;
        String tempNandu=new String(nanduData) ;
        String value="";
        int count=0;
        while(tempNandu.length()!=0)
        {
            
            if(tempNandu.indexOf(",")==-1)
            {
                value=tempNandu;
                tempNandu="";
            }
            else
            {
               value=tempNandu.substring(0, tempNandu.indexOf(","));
               tempNandu=tempNandu.substring(tempNandu.indexOf(",")+1);
            }
            
            if(nandu.find(value,event)==null)
            {
                if(invalidNandu.indexOf("\'"+value+"\'")==-1)
                    invalidNandu+="\'"+value+"\'\n";
                Output.append("Cannot find nandu "+value+" for "+athleteName+" in the event "+event+" \n");
                retVal=false;                
            }
            count++;
        }
        return retVal;
    }
    
    //verify if the nandu point is good
    boolean verifyNanduScore(Publisher output,String athleteName,String nanduData,String event,Vector nanduPointsEntered)
    {
        boolean printFullSummary=(nanduPointsEntered.size()>0);
        
        String report=new String();
        report+="<TABLE border=\"2\" cellpadding=\"8\">";
        report+="<tr>";
            report+="<TD> Name </TD>";
            report+="<TD> "+athleteName+" </TD>";
        report+="</tr>";

        report+="<tr>";
            report+="<TD> Event </TD>";
            report+="<TD> "+event+" </TD>";
        report+="</tr>";

        report+="<tr>";
            report+="<TD> Nandu Code </TD>";
            report+="<TD> Description </TD>";
            if(printFullSummary)
                report+="<TD> Max Points Allowed by rule</TD>";
            report+="<TD> Valid Points Allocated</TD>";
            if(printFullSummary)
                report+="<TD> Points Entered by Athlete</TD>";
        report+="</tr>";

        double totalDifficultyScore=0.0;
        double totalTransitionScore=0.0;
        double rawTotalDifficultyScore=0.0;
        double rawTotalTransitionScore=0.0;
        double maxDifficultyScore=1.4;
        double maxTransitionScore=0.6;

        //go through all the nandu blocks
        for(int i=0;i<nandu.getNanduCount(nanduData);i++)
        {
            String nanduName=nandu.getNandu(i,nanduData);
            nanduData.nandu nanduDesc=nandu.find(nanduName);
            String pointsAllocated="";
            String reformattedNanduPointsEntered="";
            //go throught all the movement
            for(int j=0;j<nanduDesc.getTotalMovements();j++)
            {
                String currCode=nanduDesc.getCode(j);
                double currPoint=nanduDesc.getPoint(j);
                String currType="";
                if(j%2==1)
                {
                    rawTotalTransitionScore+=currPoint;
                    if(currPoint>maxTransitionScore-totalTransitionScore)
                        currPoint=maxTransitionScore-totalTransitionScore;                        
                    totalTransitionScore+= currPoint;
                    currType="T";
                }
                else
                {
                    rawTotalDifficultyScore+=currPoint;
                    if(currPoint>maxDifficultyScore-totalDifficultyScore)
                        currPoint=maxDifficultyScore-totalDifficultyScore; 
                    totalDifficultyScore+= currPoint;
                    currType="D";
                }
                if(j>0)
                    pointsAllocated+=",";
                pointsAllocated+=String.format("%.2f",currPoint);
                //Output.append("Nandu : "+currCode+" Point : "+currPoint+" Type : "+currType+"\n");
            }

            //////////////////////////////////////////////////////////////////////
            //reformat entered nandu so it can be easily compared
            if(i<nanduPointsEntered.size())
            {                
                StringTokenizer stringTokens = new StringTokenizer((String)nanduPointsEntered.get(i), ",");
                int tCount=0;
                while(stringTokens.hasMoreTokens())
                {
                    String currToken=stringTokens.nextToken();
                     double currPointsSeperatedFloat = 0.0;
                    try
                    {
                      currPointsSeperatedFloat=Double.parseDouble(currToken.trim());
                    }
                    catch (NumberFormatException e)
                    {
                    }
                    if(tCount>0)
                        reformattedNanduPointsEntered+=",";
                    reformattedNanduPointsEntered+=String.format("%.2f",currPointsSeperatedFloat);
                    tCount++;
                }
                //report+="<TD> "+(String)nanduPointsEntered.get(i)+" </TD>";
            }
            //////////////////////////////////////////////////////////////////////
            
            report+="<tr>";
            //report+="<TD> "+nanduDesc.code+"</TD>";
            report+="<TD> "+nanduName+"</TD>";
            report+="<TD> "+nanduDesc.description+"</TD>";
            if(printFullSummary)
            {
                report+="<TD> "+nanduDesc.points+" </TD>";
                if(pointsAllocated.equals(reformattedNanduPointsEntered))
                {
                    report+="<TD> "+pointsAllocated+" </TD>";
                    report+="<TD> "+reformattedNanduPointsEntered+" </TD>";
                }
                else
                {
                    report+="<TD> <font color=\"red\">"+pointsAllocated+"</font> </TD>";
                    report+="<TD> <font color=\"red\">"+reformattedNanduPointsEntered+"</font></TD>";   
                }
            }else
            {
                report+="<TD> "+pointsAllocated+" </TD>";
            }
            report+="</tr>";
        }
        
        report+="<tr>";
            report+="<TD> Transition </TD>";
            report+="<TD> </TD>";
            if(printFullSummary)
                report+="<TD> "+String.format("%.2f",rawTotalTransitionScore)+" </TD>";
            report+="<TD> "+String.format("%.2f",totalTransitionScore)+" </TD>";
        report+="</tr>";
        
        report+="<tr>";
            report+="<TD> Movement </TD>";
            report+="<TD> </TD>";
            if(printFullSummary)
                report+="<TD> "+String.format("%.2f",rawTotalDifficultyScore)+" </TD>";
            report+="<TD> "+String.format("%.2f",totalDifficultyScore)+" </TD>";
        report+="</tr>";
        
        report+="<tr>";
            report+="<TD> Total </TD>";
            report+="<TD> </TD>";
            if(printFullSummary)
                report+="<TD> "+String.format("%.2f",rawTotalTransitionScore+rawTotalDifficultyScore)+" </TD>";
            report+="<TD> "+String.format("%.2f",totalTransitionScore+totalDifficultyScore)+" </TD>";
        report+="</tr>";
        report+="</TABLE>";
        report+="\n\n";
        
        
        
        
        //////////////////////////////////////////////
        //Publisher output=new Publisher("..\\data\\nanduReport.html");
        output.dump("<html>");  
        
            output.dump("<head>");
                output.dump("<title>");
                    output.dump("Nandu Report");
                output.dump("</title>");
            output.dump("</head>");

            output.dump("<body>");
                output.dump("<pre>");
                
                output.dump(report);
                
                output.dump("</pre>");
           output.dump("</body>");               
        output.dump("</html>"); 
        //////////////////////////////////////////////
        
       
//        //go throught all the individual movement
//        for(int j=0;j<nandu.getMovementsCount(nanduData);j++)
//        {
//            int l=j;
//            //go through all the nandu blocks and find the block the current movement belongs to
//            for(int k=0;k<nandu.getNanduCount(nanduData);k++)
//            {
//                nanduData.nandu nanduDesc=nandu.find(nandu.getNandu(k,nanduData));
//                if(l<nanduDesc.getTotalMovements())
//                {
//                    String currCode=nanduDesc.getCode(l);
//                    double currPoint=nanduDesc.getPoint(l);
//                    if(l % 2 == 1)
//                    {
//                        totalTransitionScore+= currPoint;
//                    }
//                    else
//                    {
//                        totalDifficultyScore+= currPoint;
//                    }
//                    Output.append("Nandu : "+currCode+" Point : "+currPoint+"\n");
//                    break;
//                }
//                l-=nanduDesc.getTotalMovements();
//            }
//        }
        
        
//        if(totalTransitionScore>.6)
//            Output.append("Transistion Nandu Range invalid "+totalTransitionScore+" for "+athleteName+" in the event "+event+" \n");
//        
//        if(totalDifficultyScore>1.4)
//            Output.append("Movement Nandu Range invalid "+totalDifficultyScore+" for "+athleteName+" in the event "+event+" \n");
//        
        if(totalTransitionScore>.6 || totalDifficultyScore>1.4)
            return false;
        return true;
    }
    
    /////////////////////////////////////////////////////////////

    
    public void printTable()
    {
        Connection connection = null;
         try 
         {
            //for mysql driver
            Class.forName(MySQLDriver).newInstance();
            String databaseURLSQL = "jdbc:mysql://" + ServerURLT.getText() +  "/" + DatabaseT.getText(); // a JDBC url
            connection = DriverManager.getConnection(databaseURLSQL, UserNameT.getText(), PasswordT.getText());
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery(querySQL);
            
            ////excel based database
            //Class.forName(ODBCDriver).newInstance();
            //connection = DriverManager.getConnection(excelDBUrl);
            //Statement statement = connection.createStatement();
            //ResultSet results = statement.executeQuery(queryExcel);
            
            printResult(results);
            results.close();
            statement.close();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
        }

        //close the connecction do not combine with prev catch because
        //updates doesn't print result 
        try 
        {
            connection.close();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
        }
    }
    
    public void printResult(ResultSet rset)
    {
        ResultSetMetaData rsmd;     //metaData
        int columnCount;            //number of columns
        try
        {
            rsmd=rset.getMetaData();
            columnCount=rsmd.getColumnCount();

            Output.append("Num of Columns :"+ columnCount+"\n\n");
            for(int col=1;col<=columnCount;col++)
            {
                Output.append(rsmd.getColumnName(col)+"\t");
            }

            Output.append("\n");                        
            //print the tuples   
            while (rset.next ())
            {
                for(int col=1;col<=columnCount;col++)
                {
                    String str=rset.getString(col);
                    if(str!=null)
                        Output.append(str+"\t");
                    else
                        Output.append("\t");
                }                        
                Output.append("\n");
            }
            Output.append("\n\n");                        
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
        }
    }
    
    public void extractSQLData(String fileName, ResultSet rset)
    {

        //some definations
        final int indexAthleteID=0;
	final int indexFirstName=1;
	final int indexLastName=2;
	final int indexEmail=3;
	final int indexGender=4;
	final int indexCollege=5;
	final int indexSchool=6;
	final int indexExperince=7;
	final int indexAgeGroup=8;
	final int indexEvent=9;
	final int indexNandu1=10;
	final int indexNandu2=11;
	final int indexNandu3=12;
	final int indexNandu4=13;

        ResultSetMetaData rsmd;     //metaData
        PrintWriter outFile;
        int columnCount;            //number of columns
        int rowCount=0;
        
        Vector vec=new Vector();
       
        //clear the nandu list
        invalidNandu="";
        
        try
        {
            outFile=new PrintWriter(new FileOutputStream(fileName)); 
            
            rsmd=rset.getMetaData();
            columnCount=rsmd.getColumnCount();
            String input[]=new String[columnCount];
            
            //create memory to read lines
            for(int col=0;col<columnCount;col++)
                input[col]=new String();

            //print the tuples   
            while (rset.next ())
            {
                String athleteID="";
                String firstName="";
                String lastName="";
                String email="";
                String gender="";
                String college="";
                String school="";
                String experince="";
                String ageGroup="";
                String event="";
                String nandu="";
                String SetupInfo="";
                String JudgeTypes="";
                String JudgeConnected="";
                String JudgeARaw="";
                String JudgeAAgree="";
                String JudgeBRaw="";
                String JudgeCRaw="";
                String JudgeCAgree="";
                String Time="";
                String Deductions="";
                String Reason="";
                String Score="0.0";
                String athleteName="";

                boolean trashEntry=false;
                for(int col=1;col<=columnCount;col++)
                {
                    String data=rset.getString (col);
                    
                    if(data==null) //if null just put blank line
                    {
                        input[col-1]="";
                        if(col==indexEvent)//TODo temporary stuff if the event name is empty
                            trashEntry=true;
                        continue;
                    }

                    //handle different cases
                    switch(col-1)
                    {
                        case indexAthleteID:
                            athleteID=data;
                            break;
                        case indexFirstName:
                            athleteName=data;
                            firstName=data;
                            break;
                        case indexLastName:
                            athleteName+=" "+data;
                            lastName=data;
                            break;
                        case indexEmail:
                            email=data;
                            break;
                        case indexGender:
                            if(data.compareToIgnoreCase("m")==0)
                                gender="Male";
                            else
                                gender="Female";
                            break;
                        case indexCollege:
                            college=data;
                            break;
                        case indexSchool:
                            school=data;
                            break;
                        case indexExperince:
                            if(data.compareToIgnoreCase("b")==0)
                                experince="Beg";
                            else if(data.compareToIgnoreCase("i") == 0)
                                experince="Int";
                            else if(data.compareToIgnoreCase("a") == 0)
                                experince="Adv";
                            break;
                        case indexAgeGroup:
//                            if(data.compareToIgnoreCase("c")==0)
//                                ageGroup="Child";
//                            else if(data.compareToIgnoreCase("y") == 0)
//                                ageGroup="Youth";
//                            else if(data.compareToIgnoreCase("j") == 0)
//                                ageGroup="Junior";
//                            else if(data.compareToIgnoreCase("a")==0)
//                                ageGroup="Adult";
//                            else if(data.compareToIgnoreCase("s") == 0)
//                                ageGroup="Senior";
                            
                            if(data.compareToIgnoreCase("a")==0)
                                ageGroup="GroupA";
                            else if(data.compareToIgnoreCase("b")==0)
                                ageGroup="GroupB";
                            else if(data.compareToIgnoreCase("c")==0)
                                ageGroup="GroupC";
                            else if(data.compareToIgnoreCase("d")==0)
                                ageGroup="Child";
                            else if(data.compareToIgnoreCase("e") == 0)
                                ageGroup="Youth";
                            else if(data.compareToIgnoreCase("y")==0)
                                ageGroup="Adult";
                            else if(data.compareToIgnoreCase("z") == 0)
                                ageGroup="Senior";
                            
                            break;
                        case indexEvent:
                              //if length is 0 skip data
                            if(data.length()==0)
                                trashEntry=true;
                            else
                            {
                                boolean found=false;
                                for(int i=0;i<vec.size();i++)
                                {
                                    if(((String)vec.get(i)).equals(data))
                                    {
                                        found=true;
                                        break;
                                    }
                                }

                                if(found==false)
                                    vec.add(data);
                            }
                            event=data;
                            break;
                        case indexNandu1:
                            nandu=data;
                            break;
                        case indexNandu2:
                            if(data.length()>0)
                                nandu+=","+data;
                            break;
                        case indexNandu3:
                            if(data.length()>0)
                                nandu+=","+data;
                            break;
                        case indexNandu4:
                            if(data.length()>0)
                                nandu+=","+data;
                            break;
                    };


                    //outFile.println(data);
                    //temporarly save the data
                    input[col-1]=data;
                    
                }

                if(!trashEntry)
                {
                    //fix and verify nandu
                    nandu=nandu.trim();
                    while(true)
                    {
                        int spaceIndex=nandu.indexOf(' ');
                        if(spaceIndex==-1)
                            break;
                        nandu=nandu.substring(0,spaceIndex)+nandu.substring(spaceIndex+1,nandu.length());
                    }
                    nandu=nandu.replace(",,", ",");
                    nandu=nandu.toUpperCase();
                    //nandu=nandu.replace(' ','\\');

                    //verify nandu if error found clear it up
                    if(verifyNandu(athleteName,nandu,event)==false)
                        nandu="";
                    //write the content to the file
                    outFile.println(athleteID);
                    outFile.println(firstName);
                    outFile.println(lastName);
                    outFile.println(email);
                    outFile.println(gender);
                    outFile.println(college);
                    outFile.println(school);
                    outFile.println(experince);
                    outFile.println(ageGroup);
                    outFile.println(event);
                    outFile.println(nandu);
                    outFile.println(SetupInfo);
                    outFile.println(JudgeTypes);
                    outFile.println(JudgeConnected);
                    outFile.println(JudgeARaw);
                    outFile.println(JudgeAAgree);
                    outFile.println(JudgeBRaw);
                    outFile.println(JudgeCRaw);
                    outFile.println(JudgeCAgree);
                    outFile.println(Time);
                    outFile.println(Deductions);
                    outFile.println(Reason);
                    outFile.println(Score);
                    outFile.println("--------------------------------------");
                    rowCount++;
                }
            }
            outFile.close();
            Output.append("Successully Downloaded\n\n");

            Output.append("Different Events\n\n");
            for(int i=0;i<vec.size();i++)
                 Output.append((String)vec.get(i)+"\n");
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
        }
        
        if(invalidNandu.length()>0)
            Output.append("\nInvalid Nandu List\n"+invalidNandu);
    
    }
    
    public void readResultTextFile(String fileName)
    {
        String AthleteID;
        String FirstName;
        String LastName;
        String Email;
        String Gender;
        String Coaches;
        String Level;
        String Event;
        String Nandu;
        String SetupInfo;
        String JudgeTypes;
        String JudgeConnected;
        String Score;
        String JudgeARaw;
        String JudgeAAgree;
        String JudgeBRaw;
        String JudgeCRaw;
        String JudgeCAgree;
        String Time;
        String Deductions;
        String Reason;
        String Extra;

        try
        {
            BufferedReader inputScript=new BufferedReader(new FileReader(fileName));
            do
            {
                AthleteID=inputScript.readLine();
                if(AthleteID==null)
                    break;
                FirstName=inputScript.readLine();
                LastName=inputScript.readLine();
                Email=inputScript.readLine();
                Gender=inputScript.readLine();
                Coaches=inputScript.readLine();
                Level=inputScript.readLine();
                Event=inputScript.readLine();
                Nandu=inputScript.readLine();
                SetupInfo=inputScript.readLine();
                JudgeTypes=inputScript.readLine();
                JudgeConnected=inputScript.readLine();
                Score=inputScript.readLine();
                JudgeARaw=inputScript.readLine();
                JudgeAAgree=inputScript.readLine();
                JudgeBRaw=inputScript.readLine();
                JudgeCRaw=inputScript.readLine();
                JudgeCAgree=inputScript.readLine();
                Time=inputScript.readLine();
                Deductions=inputScript.readLine();
                Reason=inputScript.readLine();
                Extra=inputScript.readLine();
                
                //input only if the score is valid
                if(Score.length()!=0)
                {
                    //update the SQL database
                    String query="update[tournament$] set Score='"+Score+"' where AthleteID="+AthleteID+" and Event='"+Event+"'";
                    
                     //for mysql driver
                    Class.forName(MySQLDriver).newInstance();
                    String databaseURLSQL = "jdbc:mysql://" + ServerURLT.getText() +  "/" + DatabaseT.getText(); // a JDBC url
                    Connection connection = DriverManager.getConnection(databaseURLSQL, UserNameT.getText(), PasswordT.getText());
                    ////excel based database
                    //Class.forName(ODBCDriver).newInstance();
                    //Connection connection = DriverManager.getConnection(excelDBUrl);
                    Statement statement = connection.createStatement();
                    statement.execute(query);
                    statement.close();
                    connection.close();
                }

            }while(true);
            inputScript.close();
            Output.append("Successully Updated\n");
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        //prints final table
        printTable();
    }
    
    //searches athletes name and returns athelete ID
    public int getAthleteIDFromRegistrationFile(Vector regAthleteIDs, Vector regAthleteNames, String athleteName)
    {
        for(int i=0;i<regAthleteNames.size();i++)
        {
            String currentAthleteName=(String)regAthleteNames.get(i);
            int currentAthleteIDs=Integer.parseInt((String)regAthleteIDs.get(i));  
            if(currentAthleteName.toLowerCase().equals(athleteName.toLowerCase())==true)
                return currentAthleteIDs;            
        }        
       
        //System.out.println("Error : Athlete ID not found"+athleteName); 
        //return -1;
        
        //if the athlete is not found add them
        int newID=regAthleteIDs.size()+1;
        regAthleteNames.add(athleteName);
        regAthleteIDs.add(Integer.toString(newID));
        System.out.println("Info : Athlete added : "+athleteName); 
        return newID;
        //////////////////////////////////////////////////////
    }
    //reads from text file format that was used for teamtrials 2013
    public void readDatabaseFromTextFileTeamTrials(String inRegistrationFileName,String inDataFileName,String outfileName)
    {
       
        int totalFormsAdded=0;
        //////////////////////////////////////////////////////
        //read registration file
        Vector regAthleteIDs=new Vector();
        Vector regAthleteNames=new Vector();
        try
        {
            BufferedReader inputScript=new BufferedReader(new FileReader(inRegistrationFileName));
            do
            {
                
                String temp=inputScript.readLine();
                if(temp==null)
                    break;
                //seperate columns
                String[] columnDetail = temp.split("\t", -1);
                //System.out.println(columnDetail[0]+" "+columnDetail[5]+" "+columnDetail[6]);
                regAthleteIDs.add(columnDetail[0]);
                regAthleteNames.add(new String(columnDetail[5]+" "+columnDetail[6]));
            }while(true);
            inputScript.close();
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        //////////////////////////////////////////////////////
        
        
        Publisher output=new Publisher("..\\data\\nanduComparisionReport.html");
        output.clear();
        Vector vec=new Vector();
        try
        {
            BufferedReader inputScript=new BufferedReader(new FileReader(inDataFileName));
            PrintWriter outFile=new PrintWriter(new FileOutputStream(outfileName)); 
            do
            {
                
                String temp=inputScript.readLine();
                if(temp==null || temp.length()==0)
                    break;
                                
                //seperate columns
                String[] columnDetail = temp.split("\t", -1);
                                
                
                Vector nanduNames=new Vector();
                Vector nanduNamesSeperated=new Vector();
                Vector nanduPointsSeperated=new Vector();
                {
                    //compute nandu
                    int sectionNanduStartIndex=9;
                    int sectionNanduCodeSectionCount[]={17,11,9,9};
                    int sectionNanduPointSectionCount[]={17,11,9,9};                
                    int i=sectionNanduStartIndex;
                    for(int s=0;s<sectionNanduCodeSectionCount.length;s++)
                    {
                        String currNandu="";
                        String currNanduSeperated="";
                        String currPointsSeperated="";
                        String delayedAddStr0="";//used for adding comma
                        String delayedAddStr1="";//used for adding comma
                        for(int j=0;j<sectionNanduCodeSectionCount[s];j++,i++)
                        {
                            String nanduName=columnDetail[i].trim();
                            String nanduPoint=columnDetail[i+sectionNanduCodeSectionCount[s]];
                            nanduPoint=nanduPoint.replace("(", " ");
                            nanduPoint=nanduPoint.replace(")", " ");
                            nanduPoint=nanduPoint.trim();

                            if(nanduName.length()==0)
                            {
                                if(currNanduSeperated.length()>0)
                                {
                                    //System.out.print("["+currNandu+"|"+currPoints+"]");
                                    nanduNames.add(currNandu);
                                    nanduNamesSeperated.add(currNanduSeperated);
                                    nanduPointsSeperated.add(currPointsSeperated);
                                    currNandu="";
                                    currNanduSeperated="";
                                    currPointsSeperated="";
                                    delayedAddStr0="";
                                    delayedAddStr1="";
                                }
                            }
                            else
                            {
                                currNanduSeperated+=delayedAddStr0;                            
                                currNanduSeperated+=nanduName;
                                currNandu+=nanduName;
                            }

                            if(nanduPoint.length()>0)
                            {
                                currPointsSeperated+=delayedAddStr1;
                                currPointsSeperated+=nanduPoint;  
                                delayedAddStr0=",";
                                delayedAddStr1=",";
                            }
                        }    
                        if(currNanduSeperated.length()>0)
                        {
                            //System.out.print("["+currNandu+"|"+currPoints+"]");
                            nanduNames.add(currNandu);
                            nanduNamesSeperated.add(currNanduSeperated);
                            nanduPointsSeperated.add(currPointsSeperated);
                        }
                        i+=sectionNanduPointSectionCount[s];                    
                        //System.out.println("");
                    }
                }
                
                //if(totalFormsAdded==201)
                //    totalFormsAdded=totalFormsAdded;
                
                //System.out.println("Name : "+columnDetail[0]+" "+columnDetail[1]+" "+totalFormsAdded);
//                System.out.println("Sex : "+columnDetail[2]);
//                System.out.println("Event : "+columnDetail[3]);
//                System.out.print("Nandu : ");                
//                for(int i=0;i<nanduNamesSeperated.size();i++)
//                {
//                    System.out.print((String)nanduNames.get(i));
//                    if(i+1<nanduNamesSeperated.size())
//                        System.out.print(",");
//                }
//                System.out.println("");
                
                
                if(columnDetail[1].trim().length()==0)//if the name entry is blank skip
                    continue;
                
                AthleteFileData athlete=new  AthleteFileData();
                
                athlete.FirstName=columnDetail[1];
                athlete.LastName=columnDetail[0];
                athlete.AthleteID=Integer.toString(getAthleteIDFromRegistrationFile(regAthleteIDs,regAthleteNames,new String(athlete.FirstName+" "+athlete.LastName)));
                athlete.Email="";
                if(columnDetail[2].toLowerCase().equals("m")==true)
                    athlete.Gender="Male";
                else
                    athlete.Gender="Female";
                athlete.College="";
                athlete.School="";
                athlete.Experience="Adv";
                athlete.AgeGroup="Youth";
                                

                /////////////////////////////////////////////////////////////////////////////////////////////
                athlete.Event="";
                
                if(columnDetail[3].toLowerCase().equals("optional changquan*")==true)athlete.Event="Changquan";
                else if(columnDetail[3].toLowerCase().equals("optional nanquan*")==true)athlete.Event="Nanquan";
                else if(columnDetail[3].toLowerCase().equals("cnn")==true)athlete.Event="ChangquanNoNandu";
                else if(columnDetail[3].toLowerCase().equals("nnn")==true)athlete.Event="NanquanNoNandu";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory changquan")==true)athlete.Event="ChangquanA";
                else if(columnDetail[3].toLowerCase().equals("1st set compulsory changquan")==true)athlete.Event="ChangquanB";
                else if(columnDetail[3].toLowerCase().equals("elementary changquan")==true)athlete.Event="ChangquanC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory nanquan")==true)athlete.Event="NanquanA";
                else if(columnDetail[3].toLowerCase().equals("international compulsory nanquan")==true)athlete.Event="NanquanB";
                else if(columnDetail[3].toLowerCase().equals("")==true)athlete.Event="NanquanC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory taijiquan")==true)athlete.Event="TaijiquanA";
                else if(columnDetail[3].toLowerCase().equals("42 forms taijiquan")==true)athlete.Event="TaijiquanB";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="TaijiquanC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory jianshu")==true)athlete.Event="StraightswordA"; 
                else if(columnDetail[3].toLowerCase().equals("1st set compulsory jianshu")==true)athlete.Event="StraightswordB"; 
                else if(columnDetail[3].toLowerCase().equals("elementary jianshu")==true)athlete.Event="StraightswordC"; 
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory daoshu")==true)athlete.Event="BroadswordA";
                else if(columnDetail[3].toLowerCase().equals("1st set compulsory daoshu")==true)athlete.Event="BroadswordB";
                else if(columnDetail[3].toLowerCase().equals("elementary daoshu")==true)athlete.Event="BroadswordC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory qianshu")==true)athlete.Event="SpearA"; 
                else if(columnDetail[3].toLowerCase().equals("1st set compulsory qianshu")==true)athlete.Event="SpearB"; 
                else if(columnDetail[3].toLowerCase().equals("elementary qianshu")==true)athlete.Event="SpearC"; 
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory gunshu")==true)athlete.Event="StaffA"; 
                else if(columnDetail[3].toLowerCase().equals("1st set compulsory gunshu")==true)athlete.Event="StaffB"; 
                else if(columnDetail[3].toLowerCase().equals("elementary gunshu")==true)athlete.Event="StaffC"; 
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory nandao")==true)athlete.Event="NandaoA";
                else if(columnDetail[3].toLowerCase().equals("international compulsory nandao")==true)athlete.Event="NandaoB";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="NandaoC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory nangun")==true)athlete.Event="NangunA";
                else if(columnDetail[3].toLowerCase().equals("international compulsory nangun")==true)athlete.Event="NangunB";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="NangunC";
                
                else if(columnDetail[3].toLowerCase().equals("3rd compulsory taijijian")==true)athlete.Event="TaijiWeaponA";
                else if(columnDetail[3].toLowerCase().equals("42 forms taijijian")==true)athlete.Event="TaijiWeaponB";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="TaijiWeaponC";
                
                else if(columnDetail[3].toLowerCase().equals("optional jianshu*")==true)athlete.Event="Straightsword";
                else if(columnDetail[3].toLowerCase().equals("optional daoshu*")==true)athlete.Event="Broadsword"; 
                else if(columnDetail[3].toLowerCase().equals("optional nandao*")==true)athlete.Event="Nandao"; 
                else if(columnDetail[3].toLowerCase().equals("optional gunshu")==true)athlete.Event="Staff";
                else if(columnDetail[3].toLowerCase().equals("optional qiangshu")==true)athlete.Event="Spear";
                else if(columnDetail[3].toLowerCase().equals("optional nangun")==true)athlete.Event="Nangun"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="OpenBarehand"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="OpenWeapon"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="TaijiquanNoNandu"; 
                else if(columnDetail[3].toLowerCase().equals("taijijian*")==true)athlete.Event="TaijiWeapon";
                else if(columnDetail[3].toLowerCase().equals("optional taijiquan*")==true)athlete.Event="Taijiquan";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="NorthTradionalBarehand";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="NorthTradionalWeapon"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="SouthTradionalBarehand";
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="SouthTradionalWeapon"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="GroupSet"; 
                else if(columnDetail[3].toLowerCase().equals("ooo")==true)athlete.Event="SparringSet";
                else
                    System.out.println("Error : Event not found "+athlete.FirstName+" : "+columnDetail[3].toLowerCase());
                boolean found=false;
                for(int i=0;i<vec.size();i++)
                {
                    if(((String)vec.get(i)).equals(athlete.Event))
                    {
                        found=true;
                        break;
                    }
                }
                if(found==false)
                    vec.add(athlete.Event);
                /////////////////////////////////////////////////////////////////////////////////////////////
                
                
                /////////////////////////////////////////////////////////////////////////////////////////////
                //find and verify nandu
                String nandu="";
                for(int i=0;i<nanduNamesSeperated.size();i++)
                {
                    nandu+=(String)nanduNames.get(i);
                    if(i+1<nanduNamesSeperated.size())
                        nandu+=",";
                }
                if(verifyNandu(athlete.FirstName+" "+athlete.LastName,nandu,athlete.Event)==false)
                    nandu="";
                
                verifyNanduScore(output,athlete.FirstName+" "+athlete.LastName,nandu,athlete.Event,nanduPointsSeperated);
                /////////////////////////////////////////////////////////////////////////////////////////////
                
                athlete.Nandu=nandu;
                athlete.SetupInfo="";
                athlete.JudgeTypes="";
                athlete.JudgeConnected="";
                athlete.JudgeARaw="";
                athlete.JudgeAAgree="";
                athlete.JudgeBRaw="";
                athlete.JudgeCRaw="";
                athlete.JudgeCAgree="";
                athlete.Time="";
                athlete.Deductions="";
                athlete.Reason="";
                athlete.Score="";   
                
                //System.out.println(athlete.FirstName+" "+athlete.LastName+" "+athlete.Nandu);
                
                //write the content to the file
                outFile.println(athlete.AthleteID);
                outFile.println(athlete.FirstName);
                outFile.println(athlete.LastName);
                outFile.println(athlete.Email);
                outFile.println(athlete.Gender);
                outFile.println(athlete.College);
                outFile.println(athlete.School);
                outFile.println(athlete.Experience);
                outFile.println(athlete.AgeGroup);
                outFile.println(athlete.Event);
                outFile.println(athlete.Nandu);
                outFile.println(athlete.SetupInfo);
                outFile.println(athlete.JudgeTypes);
                outFile.println(athlete.JudgeConnected);
                outFile.println(athlete.JudgeARaw);
                outFile.println(athlete.JudgeAAgree);
                outFile.println(athlete.JudgeBRaw);
                outFile.println(athlete.JudgeCRaw);
                outFile.println(athlete.JudgeCAgree);
                outFile.println(athlete.Time);
                outFile.println(athlete.Deductions);
                outFile.println(athlete.Reason);
                outFile.println(athlete.Score);
                outFile.println("--------------------------------------");
                
                totalFormsAdded++;

            }while(true);
            inputScript.close();
            outFile.close();
            Output.append("Successully Read\n");
            Output.append("Different Events\n\n");
            for(int i=0;i<vec.size();i++)
                 Output.append((String)vec.get(i)+"\n");
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        //prints final table
        //printTable();
    }
    
    
    private void DownloadSQLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DownloadSQLActionPerformed
       
         try
         {
             //load the drive    
             Class.forName(MySQLDriver).newInstance();
             //connect to the database
             String databaseURLSQL = "jdbc:mysql://" + ServerURLT.getText() +  "/" + DatabaseT.getText(); // a JDBC url
             Connection connection = DriverManager.getConnection(databaseURLSQL, UserNameT.getText(), PasswordT.getText());
             Statement statement = connection.createStatement();
             ResultSet results = statement.executeQuery(querySQL);
             
//             //for excel based connection
//             Class.forName(ODBCDriver).newInstance();
//             Connection connection = DriverManager.getConnection(excelDBUrl);
//             Statement statement = connection.createStatement();
//             ResultSet results = statement.executeQuery(queryExcel);
             
             Output.setText("");
             //save the sql data
             extractSQLData(DownloadFileNameT.getText(),results);
             
             results.close();
             statement.close();
             connection.close();
              
         }
         catch (Exception e)
         {
            JOptionPane.showMessageDialog(this, e.toString() , "Error", JOptionPane.DEFAULT_OPTION);
         }
         
         //put data into correct event
        adjustEvent();  
    }//GEN-LAST:event_DownloadSQLActionPerformed

    private void mergeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mergeActionPerformed
         //merge two files
        mergeFiles(src1.getText(),src2.getText(),out.getText());
        Output.append("Merge complete \n");
        Output.append("Rename the output file to athletes.txt and open head judge program. Then hit publish to compute the merged result \n");

    }//GEN-LAST:event_mergeActionPerformed

private void AddAthletesBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddAthletesBActionPerformed
    //if the form doesn't exist create one
    if(modifyAthletes==null)
    {
        modifyAthletes=new ModifyAthletes(null, false);
        //add the nandu data
        modifyAthletes.setNanduData(nandu);
    }
    
    //adds lists
    modifyAthletes.addGenderList(setupInfo.getGenderList());
    modifyAthletes.addEventList(setupInfo.getEventList());
    modifyAthletes.addLevelList(setupInfo.getLevelList());
    modifyAthletes.addAgeGroupList(setupInfo.getAgeGroupList());
        
    //make final summary visible
    if (modifyAthletes.isVisible() == false)
        modifyAthletes.setVisible(true);
    
    if(modifyAthletes.SaveClicked())
    {
        Vector AthleteListFileData=new Vector();
        //read the 1st file
        readInputTextFile(DownloadFileNameT.getText(),AthleteListFileData);
        
        //find the maximum ID used
        int maxAthleteID=0;
        for(int i=0;i<AthleteListFileData.size();i++)
        {
            Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(i);
            int currAthleteID=Integer.parseInt(ad.AthleteID);
            if(maxAthleteID<currAthleteID)
                maxAthleteID=currAthleteID;
        }
        int newAthleteID=maxAthleteID+1;
        //returns the current athletes data
        AthleteFileData aData[]=modifyAthletes.getAthleteData();
        //need way to write aData
        for(int i=0;i<aData.length;i++)
        {
            AthleteFileData currAthleteData=aData[i];
            //add the athlete id and save in the file
            currAthleteData.AthleteID=Integer.toString(newAthleteID);
            AthleteListFileData.add(currAthleteData);
        }
        //write the merged file
        writeOutputFile(DownloadFileNameT.getText(),AthleteListFileData);
        writeOutputFile("../data/athletesSimple.txt",AthleteListFileData);
    }
}//GEN-LAST:event_AddAthletesBActionPerformed

private void ModifyAthletesBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ModifyAthletesBActionPerformed

    //if the form doesn't exist create one
    if(viewerAthletes==null)
    {
        viewerAthletes=new Viewer(null, false);
        //add the nandu data
        viewerAthletes.setNanduData(nandu);
    }
          
     Vector AthleteListFileData=new Vector();
     //read the 1st file
     readInputTextFile(DownloadFileNameT.getText(),AthleteListFileData);
     
     viewerAthletes.enableModifyAthletes();
     //update the athletes list
     viewerAthletes.updateAthletes(AthleteListFileData);
     
     
     
    //make final summary visible
    if (viewerAthletes.isVisible() == false)
        viewerAthletes.setVisible(true);
     

    
    if(viewerAthletes.SaveClicked())
    {
        Vector newAthleteListFileData= viewerAthletes.getAthletesList();
        
        //write the merged file
        writeOutputFile(DownloadFileNameT.getText(),newAthleteListFileData);
        writeOutputFile("../data/athletesSimple.txt",newAthleteListFileData);

    }
        
        
}//GEN-LAST:event_ModifyAthletesBActionPerformed

    //put data into correct event
    private void adjustEvent()
    {        
       Vector AthleteListFileData=new Vector();
       Vector newAthleteListFileData=new Vector();
       //read the 1st file
       readInputTextFile(DownloadFileNameT.getText(),AthleteListFileData);
       
       String genderList[]=setupInfo.getGenderList();
       String levelList[]=setupInfo.getLevelList();
       String ageList[]=setupInfo.getAgeGroupList();
       String eventList[]=setupInfo.getEventList();
       
       //////////////////////////////////////////////////////////////////////////////////
       //first check that every gender are in the list
       for(int i=0;i<AthleteListFileData.size();i++)
       {
           Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(i); 
           boolean eventFound=false;
           for(int j=0;j<genderList.length;j++)
           {
               String currEvent=((String)genderList[j]);
               if(currEvent.toLowerCase().equals(ad.Gender.toLowerCase())==false)
                   continue;
               eventFound=true;
               break;
            }
           if(eventFound==false)
           {
               System.out.println("Error : Gender not found "+ad.Gender.toLowerCase()+" Please add the gender into data/setup.ini.");
           }
        }       
        //////////////////////////////////////////////////////////////////////////////////
       
       
       //////////////////////////////////////////////////////////////////////////////////
       //first check that every experience are in the list
       for(int i=0;i<AthleteListFileData.size();i++)
       {
           Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(i); 
           boolean eventFound=false;
           for(int j=0;j<levelList.length;j++)
           {
               String currEvent=((String)levelList[j]);
               if(currEvent.toLowerCase().equals(ad.Experience.toLowerCase())==false)
                   continue;
               eventFound=true;
               break;
            }
           if(eventFound==false)
           {
               System.out.println("Error : Level not found "+ad.Experience.toLowerCase()+" Please add the level into data/setup.ini.");
           }
        }       
        //////////////////////////////////////////////////////////////////////////////////
       
       
        //////////////////////////////////////////////////////////////////////////////////
       //first check that every Age are in the list
       for(int i=0;i<AthleteListFileData.size();i++)
       {
           Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(i); 
           boolean eventFound=false;
           for(int j=0;j<ageList.length;j++)
           {
               String currEvent=((String)ageList[j]);
               if(currEvent.toLowerCase().equals(ad.AgeGroup.toLowerCase())==false)
                   continue;
               eventFound=true;
               break;
            }
           if(eventFound==false)
           {
               System.out.println("Error : Age not found "+ad.AgeGroup.toLowerCase()+" Please add the age into data/setup.ini.");
           }
        }       
        //////////////////////////////////////////////////////////////////////////////////
       
       
        //////////////////////////////////////////////////////////////////////////////////
       //first check that every nandus are in the list
       for(int i=0;i<AthleteListFileData.size();i++)
       {
           Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(i); 
           boolean eventFound=false;
           for(int j=0;j<eventList.length;j++)
           {
               String currEvent=((String)eventList[j]);
               if(currEvent.toLowerCase().equals(ad.Event.toLowerCase())==false)
                   continue;
               eventFound=true;
               break;
            }
           if(eventFound==false)
           {
               System.out.println("Error : Event not found "+ad.Event.toLowerCase()+" Please add the event into data/setup.ini.");
           }
        }       
        //////////////////////////////////////////////////////////////////////////////////
       
       
              
       /////////////////////////////////////////////////////////////////////////////////
       //update teh cells based on event order
       for(int i=0;i<ageList.length;i++)
       {
           String currAge=((String)ageList[i]);
            for(int j=0;j<levelList.length;j++)
            {
                String currLevel=((String)levelList[j]);
                for(int k=0;k<genderList.length;k++)
                {              
                    String currGender=((String)genderList[k]);
                    for(int l=0;l<eventList.length;l++)
                    {
                        String currEvent=((String)eventList[l]);
                        for(int m=0;m<AthleteListFileData.size();m++)
                        {
                            Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(m);
                            if(
                                    currAge.toLowerCase().equals(ad.AgeGroup.toLowerCase())==true &&
                                    currLevel.toLowerCase().equals(ad.Experience.toLowerCase())==true &&
                                    currGender.toLowerCase().equals(ad.Gender.toLowerCase())==true &&
                                    currEvent.toLowerCase().equals(ad.Event.toLowerCase())==true 
                               )
                            {
                                //add the event
                                newAthleteListFileData.add(ad);
                            }
                        }
                        
                        
                    }
                }
            }
       }
    
//            
//            genderList;
//            levelList;
//            ageList;
//            
//            
//            
////            for(int j=0;j<AthleteListFileData.size();j++)
////            {
////                Main.AthleteFileData ad=(Main.AthleteFileData)AthleteListFileData.elementAt(j);
////                if(currEvent.toLowerCase().equals(ad.Event.toLowerCase())==true)
////                {
////                    //add the event
////                    newAthleteListFileData.add(ad);
////                }
////            }
//        }
//        /////////////////////////////////////////////////////////////////////////////////
       
       
       writeOutputFile(DownloadFileNameT.getText(),newAthleteListFileData);
       writeOutputFile("../data/athletesSimple.txt",newAthleteListFileData);
    }

    private void ReadDataFromTextFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadDataFromTextFileActionPerformed
       readDatabaseFromTextFileTeamTrials("../data/TeamTrialsRegistration.txt","../data/TeamTrialsData.txt",DownloadFileNameT.getText());
       //hack
       readDatabaseFromTextFileTeamTrials("../data/TeamTrialsRegistration.txt","../data/TeamTrialsData.txt","../data/athletesSimple.txt");
       
       //put data into correct event
       adjustEvent();       
    }//GEN-LAST:event_ReadDataFromTextFileActionPerformed

    private void PrintEventReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintEventReportActionPerformed
        
        Publisher nanduReportOutput=new Publisher("..\\data\\nanduReport.html");
        nanduReportOutput.clear();
        Vector nanduPointsEntered=new Vector();
        Vector AthleteListFileData=new Vector();
        //read the 1st file
        readInputTextFile(DownloadFileNameT.getText(),AthleteListFileData);
        for(int i=0;i<AthleteListFileData.size();i++)
        {
            AthleteFileData athlete=(AthleteFileData)AthleteListFileData.elementAt(i);
            int scoringSystem=getScoringSystem(athlete.Experience,athlete.Event);
            if(scoringSystem==2)//for nandu system
                verifyNanduScore(nanduReportOutput,athlete.FirstName+" "+athlete.LastName,athlete.Nandu,athlete.Event,nanduPointsEntered);
        }
    }//GEN-LAST:event_PrintEventReportActionPerformed

    private void RandomizeOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RandomizeOrderActionPerformed
        //if the form doesn't exist create one
        if(viewerAthletes==null)
        {
            viewerAthletes=new Viewer(null, false);
            //add the nandu data
            viewerAthletes.setNanduData(nandu);
        }

        Vector AthleteListFileData=new Vector();
        //read the 1st file
        readInputTextFile(DownloadFileNameT.getText(),AthleteListFileData);
        
        //get all th groups
        HashSet groupList=getGroups(AthleteListFileData);
        viewerAthletes.updateGroups(groupList);
        viewerAthletes.enableRandomizeAthletes();
        
        //update the athletes list
        viewerAthletes.updateAthletesOrder(AthleteListFileData);
        
        

        //make final summary visible
        if (viewerAthletes.isVisible() == false)
            viewerAthletes.setVisible(true);

        if(viewerAthletes.SaveClicked())
        {
            Vector newAthleteListFileData= viewerAthletes.getAthletesList();

            //write the merged file
            writeOutputFile(DownloadFileNameT.getText(),newAthleteListFileData);
            writeOutputFile("../data/athletesSimple.txt",newAthleteListFileData);
        }
    }//GEN-LAST:event_RandomizeOrderActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    static public class AthleteFileData
    {
        public String AthleteID;
        public String FirstName;
        public String LastName;
        public String Email;
        public String Gender;
        public String College;
        public String School;
        public String Experience;
        public String AgeGroup;
        public String Event;
        public String Nandu;
        public String SetupInfo;
        public String JudgeTypes;
        public String JudgeConnected;
        public String JudgeARaw;
        public String JudgeAAgree;
        public String JudgeBRaw;
        public String JudgeCRaw;
        public String JudgeCAgree;
        public String Time;
        public String Deductions;
        public String Reason;
        public String Score;
    };

    //read the Input Text File where all the athletes info is saved
    public void readInputTextFile(String fileName,Vector AthleteList)
    {
        String Extra;
        try
        {
            BufferedReader inputScript=new BufferedReader(new FileReader(fileName));
            do
            {
                AthleteFileData athlete=new  AthleteFileData();
                athlete.AthleteID=inputScript.readLine();
                if(athlete.AthleteID==null)
                    break;
                athlete.FirstName=inputScript.readLine();
                athlete.LastName=inputScript.readLine();
                athlete.Email=inputScript.readLine();
                athlete.Gender=inputScript.readLine();
                athlete.College=inputScript.readLine();
                athlete.School=inputScript.readLine();
                athlete.Experience=inputScript.readLine();
                athlete.AgeGroup=inputScript.readLine();
                athlete.Event=inputScript.readLine();
                athlete.Nandu=inputScript.readLine();
                athlete.SetupInfo=inputScript.readLine();
                athlete.JudgeTypes=inputScript.readLine();
                athlete.JudgeConnected=inputScript.readLine();
                athlete.JudgeARaw=inputScript.readLine();
                athlete.JudgeAAgree=inputScript.readLine();
                athlete.JudgeBRaw=inputScript.readLine();
                athlete.JudgeCRaw=inputScript.readLine();
                athlete.JudgeCAgree=inputScript.readLine();
                athlete.Time=inputScript.readLine();
                athlete.Deductions=inputScript.readLine();
                athlete.Reason=inputScript.readLine();
                athlete.Score=inputScript.readLine();

                //read extra line ---------------
                Extra=inputScript.readLine();

                //add the athlere list
                AthleteList.add(athlete);
            }while(true);
        }
        catch(Exception e)
        {
            Output.append("Error : " + e.getMessage()+"\n");
        }
    }

    public void writeOutputFile(String fileName,Vector AthleteList)
    {
        PrintWriter outFile;
        try
        {
            outFile=new PrintWriter(new FileOutputStream(fileName));

            //print the tuples
            for(int i=0;i<AthleteList.size();i++)
            {
                AthleteFileData athlete=(AthleteFileData)AthleteList.get(i);

                outFile.println(athlete.AthleteID);
                outFile.println(athlete.FirstName);
                outFile.println(athlete.LastName);
                outFile.println(athlete.Email);
                outFile.println(athlete.Gender);
                outFile.println(athlete.College);
                outFile.println(athlete.School);
                outFile.println(athlete.Experience);
                outFile.println(athlete.AgeGroup);
                outFile.println(athlete.Event);
                outFile.println(athlete.Nandu);
                outFile.println(athlete.SetupInfo);
                outFile.println(athlete.JudgeTypes);
                outFile.println(athlete.JudgeConnected);
                outFile.println(athlete.JudgeARaw);
                outFile.println(athlete.JudgeAAgree);
                outFile.println(athlete.JudgeBRaw);
                outFile.println(athlete.JudgeCRaw);
                outFile.println(athlete.JudgeCAgree);
                outFile.println(athlete.Time);
                outFile.println(athlete.Deductions);
                outFile.println(athlete.Reason);
                outFile.println(athlete.Score);
                outFile.println("--------------------------------------");
            }
            outFile.close();
        }
        catch(Exception e)
        {
            Output.append("Error : " + e.toString()+"\n");
        }

    }

    private boolean mergeFiles(String sourceFileName1, String sourceFileName2, String outputFileName)
    {
        Vector AthleteListFileData1=new Vector();
        Vector AthleteListFileData2=new Vector();
        Vector mergedFileData=new Vector();


        //read the 1st file
        readInputTextFile(sourceFileName1,AthleteListFileData1);
        readInputTextFile(sourceFileName2,AthleteListFileData2);

        //merge the data
        for(int i=0;i<AthleteListFileData1.size();i++)
        {
            AthleteFileData md;
            AthleteFileData ad1=(AthleteFileData)AthleteListFileData1.elementAt(i);

            for(int j=0;j<AthleteListFileData2.size();j++)
            {
                AthleteFileData ad2=(AthleteFileData)AthleteListFileData2.elementAt(j);

                if(ad1.FirstName.equals(ad2.FirstName)==true && ad1.LastName.equals(ad2.LastName)==true && ad1.AgeGroup.equals(ad2.AgeGroup)==true && ad1.Event.equals(ad2.Event)==true )
                {

                    if(
                        ad1.SetupInfo.length()==0 &&
                        ad1.JudgeTypes.length()==0 &&
                        ad1.JudgeConnected.length()==0 &&
                        ad1.JudgeARaw.length()==0 &&
                        ad1.JudgeAAgree.length()==0 &&
                        ad1.JudgeBRaw.length()==0 &&
                        ad1.JudgeCRaw.length()==0 &&
                        ad1.JudgeCAgree.length()==0 &&
                        ad1.Time.length()==0 &&
                        ad1.Deductions.length()==0 &&
                        ad1.Reason.length()==0 &&
                        ad1.Score.equals("0.0")==true
                      )
                        md=ad2;
                    else if(
                        ad2.SetupInfo.length()==0 &&
                        ad2.JudgeTypes.length()==0 &&
                        ad2.JudgeConnected.length()==0 &&
                        ad2.JudgeARaw.length()==0 &&
                        ad2.JudgeAAgree.length()==0 &&
                        ad2.JudgeBRaw.length()==0 &&
                        ad2.JudgeCRaw.length()==0 &&
                        ad2.JudgeCAgree.length()==0 &&
                        ad2.Time.length()==0 &&
                        ad2.Deductions.length()==0 &&
                        ad2.Reason.length()==0 &&
                        ad2.Score.equals("0.0")==true
                      )
                        md=ad1;
                    else
                    {
                        Output.append("Error : Athlete " + ad1.FirstName+" "+ad1.LastName+" has been judged twice in "+ad1.Event+" "+ad1.AgeGroup+" "+ad1.Gender+" "+ad1.Experience+"\n");
                        return false;
                    }
                    mergedFileData.add(md);
                    break;
                }
            }
        }

        //write the merged file
        writeOutputFile(outputFileName,mergedFileData);

        return true;
    }
    
    //returns the name of the group
    public HashSet getGroups(Vector AthleteListFileData)
    {
       HashSet groupList=new HashSet();

        for(int i=0;i<AthleteListFileData.size();i++)
        {
            AthleteFileData ad=(AthleteFileData)AthleteListFileData.elementAt(i);
            String temp="/";
            String data=ad.AgeGroup+temp+ad.Experience+temp+ad.Gender;
            groupList.add(data);
        }

       return groupList;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddAthletesB;
    private javax.swing.JTextField Command;
    private javax.swing.JTextField DatabaseT;
    private javax.swing.JTextField DownloadFileNameT;
    private javax.swing.JButton DownloadSQL;
    private javax.swing.JButton ModifyAthletesB;
    private javax.swing.JTextArea Output;
    private javax.swing.JPasswordField PasswordT;
    private javax.swing.JButton PrintEventReport;
    private javax.swing.JButton RandomizeOrder;
    private javax.swing.JButton ReadDataFromTextFile;
    private javax.swing.JTextField ServerURLT;
    private javax.swing.JTextField UserNameT;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton merge;
    private javax.swing.JTextField out;
    private javax.swing.JTextField src1;
    private javax.swing.JTextField src2;
    // End of variables declaration//GEN-END:variables
    
}
